package com.lzh.chatnote.chat.service.impl;

import com.lzh.chatnote.chat.domain.dto.message.PushMsgDTO;
import com.lzh.chatnote.common.constant.MQConstant;
import com.lzh.chatnote.common.mqProducer.MQProducer;
import com.lzh.chatnote.webSocket.domain.vo.resp.WSBaseResp;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

@Component
public class PushService {

    @Resource
    private MQProducer mqProducer;

    /**
     * 推送给所有用户
     */
    public void pushMsgAllUser(WSBaseResp<?> wsBaseResp){
         mqProducer.sendMsg(MQConstant.PUSH_TOPIC, new PushMsgDTO(wsBaseResp));
    }

    /**
     * 推送给群里用户
     */
    public void pushMsgRoomUser(WSBaseResp<?> wsBaseResp, List<Long> pushUids){
        mqProducer.sendMsg(MQConstant.PUSH_TOPIC, new PushMsgDTO(pushUids, wsBaseResp));
    }

    /**
     * 推送给单人用户
     */
    public void pushMsgSingleUser(WSBaseResp<?> wsBaseResp, Long pushUid){
        mqProducer.sendMsg(MQConstant.PUSH_TOPIC, new PushMsgDTO(pushUid, wsBaseResp));
    }

}
